<template>
  <div class="page-container">
    <div class="info-container">
      <div class="info-container_header">
        <div class="title">站房详情</div>
      </div>
      <div class="info-container_body">
        <el-form ref="refFrom" label-position="top" :model="form.model" class="demo">
          <div class="form-section">
            <div class="form-section_title">基础信息</div>
            <AgelFormDesc :items="form.baseItems" :column="24"> </AgelFormDesc>
          </div>
        </el-form>
      </div>
      <div class="info-container_footer">
        <el-button @click="handleCancel">返回</el-button>
      </div>
    </div>

  </div>
</template>

<script setup name="StationMessage" lang="tsx">
import { getLeakAnalysis } from '@/api/station/leak/index';

const { proxy } = getCurrentInstance() as ComponentInternalInstance;

const route = useRoute();
const orderId = toRef<string | null>(route.query.id as string)

const form = reactive({
  model: defaultStationModel(),
  baseItems: [
    { prop: "name", label: "站房名称", span: 6 },
    { prop: "contactUser", label: "责任人", span: 6 },
    { prop: "contactPhone", label: "联系电话", span: 6 },
    { prop: "regionCode", label: "省市区", span: 6 },
    { prop: "location", label: "具体地址", span: 24 },
  ],
  propItems: [
    { prop: "maxCap", label: "最大接入数量", attrs: { type: 'number' }, span: 6 },
    { prop: "pmax", label: "站房压力上限", attrs: { type: 'number' }, span: 6 },
    { prop: "pmin", label: "站房压力下限", attrs: { type: 'number' }, span: 6 },
    { prop: "omax", label: "浓度上限", attrs: { type: 'number' }, span: 6 },
    { prop: "omin", label: "浓度下限", attrs: { type: 'number' }, span: 6 },
    { prop: "eprice", label: "单位电价", attrs: { type: 'number' }, span: 6 },
    { prop: "leakThreshold", label: "最低保压时长", attrs: { type: 'number' }, span: 6 },
    { prop: "plowDays", label: "持续欠压天数", attrs: { type: 'number' }, span: 6 },
    { prop: "softExpansion", label: "是否开启软扩容", slot: 'el-switch', attrs: { activeValue: 1, inactiveValue: 0, }, viewModel: false },
    { prop: "operationalMode", label: "是否开启调试模式", slot: 'el-switch', attrs: { activeValue: '1', inactiveValue: '0', }, viewModel: false },
  ],
})
const loading = ref(false)

/** 取消 */
const handleCancel = () => {
  // proxy?.$tab.closeOpenPage()
  proxy?.$tab.closePage();
}
const getInfo = async (id: string) => {
  loading.value = true
  let res = await getLeakAnalysis(id)
  loading.value = false
  if (res.code == 200) {
    form.model = res.data
  } else {
    proxy?.$modal.msgError(res.msg || '创建失败！')
  }
}
if (orderId.value) {
  getInfo(orderId.value)
}
onMounted(() => {
})
</script>
